1. Field of the Invention
The present invention is related to allocation of computer resources, and in particular to sharing computer resources based in part on detecting an idle condition.
2. Description of the Related Art
Many conventional general-purpose computers, such as personal computers, spend a significant portion of their time executing an idle loop because these conventional computers are typically capable of executing instructions at a much faster rate than required by the software that they run. Often, even a program which is running without waiting for user interaction will often end up giving CPU cycles to the idle loop because the program is waiting for disk I/O operations, such as data transfers to or from a hard disk drive, to complete. For example, if a single disk head seek takes 10 milliseconds, the computer processor clocked at 2 gigahertz can execute 20 million idle instruction cycles during the 10 milliseconds. Each such seek which occurs per second will cause the CPU to spend an additional 1% of its time in the idle loop.
In many conventional modem operating systems, multiple programs may be run at once. A distinction is often made between the program the user is interacting with or waiting for, called the foreground process, and one or more programs that are running tasks less important to the user at the moment, called background processes. Background processes may run at a lower scheduling priority than the foreground process, so that the background processes will not unduly slow down the primary computational task. Some such background processes may voluntarily set their own priorities to a very low level, sometimes referred to as “idle priority”, in an attempt to have no or little impact on the apparent speed of the computer from the user's perspective. With such a low priority, many conventional operating systems will allow these processes to run only when the system would otherwise be running its idle loop.
Such a scheme may work adequately if a background process is only going to utilize processor computation resources. However, if the background process accesses the disk at the same time that the foreground process does, system performance may rapidly deteriorate. Because a single disk head seek can take approximately 10 milliseconds, only 100 such seeks may be performed every second. If the background process causes the disk heads to move away from the area of the disk that the foreground process was about to access next, the foreground process may spend 20 milliseconds waiting for the disk head to move to the location the background process is accessing and back again.
When the foreground process is performing tasks whose completion time is bound by disk I/O speed, such disk head seeks resulting from sharing disk access with the background process can cause the overall task completion time to take many times longer as compared to the scenario where the foreground process has exclusive use of the disk. This is because the disk may be performing many seeks where none may be needed if only one process were accessing the disk.
By way of example, one background process could be an indexing process. The indexing process may perform many disk I/O operations, such as when indexing the contents of the user's hard disk to allow the user to rapidly find files which contain certain words or phrases. Such a background process, even if set to run at “idle priority”, may greatly slow down the apparent speed of a foreground process that performs disk I/O operations because, while running, the indexing process is constantly reading from and writing to the user's hard disk.